1. Field of the Invention
The present invention relates to compilers, assemblers and preprocessors for computer programs, and more specifically to an apparatus and a method for selectively and incrementally viewing the results of preprocessing operations such as macro expansions.
2. Related Art
Computer programming languages such as C and macro assemblers provide facilities for preprocessing operations that prepare program source code for compilation or assembly. Preprocessing translates original source code into actual source code that can be compiled or assembled. For example, languages which support preprocessing typically allow programmers to define macros. A macro is an abbreviated notation for source code that is either too complicated to write out, hard to understand, used frequently, or subject to change. Before the source code is compiled, the preprocessing step translates the macro from its easy-to-read form into the actual source code specified by the macro definition.
Translating a macro into final source code is called macro expansion. After a macro has been expanded, a preprocessor may examine the result to see if it contains instances of other macros. If so, the preprocessor expands these embedded macros. This makes it possible to define macros in terms of other macros.
In a sense, macros are designed to hide distracting technical details, making it easier for a programmer to read source code. However, macros have drawbacks: when programmers are trying to debug a program, there is currently no easy way to see the code that results after macros have been expanded. Normal code editors only show the source code before preprocessing, not the expanded code after preprocessing. If, for example, a macro definition contains an error, it may produce bugs which are difficult to find, because the programmer has no good way to see the actual source code that the macro produces.
Some programming environments make it possible to view the code that results after preprocessing. However, this code may not be available in an easily readable form. Furthermore, this code is completely expanded; there is no provision for selectively viewing the expansion of specific macros or other preprocessor directives, while viewing the rest of the source code in its original form. Finally, current programming environments do not make it possible to examine intermediate phases of expansion. For example, if one macro definition makes use of another macro, there is no way for the programmer to view the code with one macro expanded but not the other.
What is needed is a method for selectively and incrementally viewing the results of the processing operations, including macro expansions.